package com.ball.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ball.dao.UserInfoDao;
import com.ball.entity.UserInfo;
import com.ball.service.UserInfoService;



@Service("userService") 
public class UserServiceImpl implements UserInfoService {

	@Resource
    private UserInfoDao userDao;
    

    
    public UserInfo getUserById(int id) {
        return userDao.selectByPrimaryKey(id);
    }

	@Override
	public UserInfo login(String userName, String password) {
		if(userName == null || password == null){
			return null;
		}
		UserInfo query =  new UserInfo();
		query.setPassword(password);
		query.setUserName(userName);
		List<UserInfo> selectByExample = userDao.selectByUserInfo(query);
		if(selectByExample == null || selectByExample.size() == 0){
			return null;
		}
		UserInfo u = selectByExample.get(0); 
		return u;
	}

}
